#include "os.h"

#ifndef OS_H
#define OS_H

FILE *fileOpenRead(const char *path) {
  FILE *file;
#ifdef MSVC
  if(!!fopen_s(&file,path,"rb")) throw "Error opening file.";
#else
  file=fopen(path,"rb");
  if(file==0) throw "Error opening file.";
#endif
  return file;
}

FILE *fileOpenWrite(const char *path) {
  FILE *file;
#ifdef MSVC
  if(!!fopen_s(&file,path,"wb")) throw "Error opening file.";
#else
  file=fopen(path,"wb");
  if(file==0) throw "Error opening file.";
#endif
  return file;
}

void stringCopyN(char *dst, size_t size, const char *src, size_t count) {
#ifdef MSVC
  if(!!strncpy_s(dst,size,src,count)) throw "Error copying string.";
#else
  strncpy(dst,src,size);
#endif
}

#endif
